package com.example.rdcproject.ving.notes.entity;

import java.util.ArrayList;
import java.util.List;

public class NewWordBook {
    //单例模式
    private static volatile NewWordBook instance;
    private List<Word> wordList; // 单词列表

    private NewWordBook() {
        wordList = new ArrayList<>();
    }

    // 获取实例的方法
    public static NewWordBook getInstance() {
        if (instance == null) {
            synchronized (NewWordBook.class) {
                if (instance == null) {
                    instance = new NewWordBook();
                }
            }
        }
        return instance;
    }

    // 添加单词到生词本中
    public void addWord(Word word) {
        wordList.add(word);
    }

    // 从生词本中移除单词
    public void removeWord(Word word) {
        wordList.remove(word);
    }

    // 获取生词本中所有单词
    public List<Word> getWordList() {
        return wordList;
    }
}
